--- @param extension Package
--- @param HY HY_Utility
--- @param U Utility
return function(extension, HY, U)
    local hy_nazuurin = General:new(extension, "hy_nazuurin", "ten_k", 3, 3, General.Female)

    local seeking_pendulum = fk.CreateSkill {
        name = "seeking_pendulum",
    }
    seeking_pendulum:addEffect(fk.TurnStart, {
        can_trigger = function(self, event, target, player, data)
            return player:hasSkill(seeking_pendulum.name)
        end,
        on_cost = Util.TrueFunc,
        on_use = function(self, event, target, player, data)
            local room = player.room
            local count = 2
            local cards = room:getNCards(count)
            local copyCards = {}
            for _, id in ipairs(cards) do
                local card = Fk:getCardById(id)
                if card.is_damage_card and not card.multiple_targets then
                    local copy = Fk:currentRoom():printCard(card.name, card.suit, card.number)
                    table.insertIfNeed(copyCards, copy)
                    room:setCardMark(copy, "@@seeking_pendulum", 1)
                    room:addTableMark(player, "seeking_pendulum", copy.id)
                end
            end
            if #copyCards == 0 then
                return
            end
            room:moveCardTo(copyCards, Card.PlayerHand, player, fk.ReasonJustMove, seeking_pendulum.name, nil, false, player)
        end
    })
    seeking_pendulum:addEffect("targetmod", {
        bypass_times = function(self, player, skill, scope, card, to)
            if card:getMark("@@seeking_pendulum") ~= 0 then
                return true
            end
        end
    })
    seeking_pendulum:addEffect(fk.TurnEnd, {
        can_refresh = function(self, event, target, player, data)
            return player:hasSkill(seeking_pendulum.name, true, true) and #player:getTableMark("seeking_pendulum") > 0
        end,
        on_refresh = function(self, event, target, player, data)
            local room = player.room
            local cards = player:getTableMark("seeking_pendulum")
            room:setPlayerMark(player, "seeking_pendulum", 0)
            room:moveCardTo(cards, Card.Void, nil, fk.ReasonJustMove, seeking_pendulum.name, nil, false)
        end
    })
    seeking_pendulum:addEffect(fk.AfterCardsMove, {
        can_refresh = function(self, event, target, player, data)
            for _, move in ipairs(data) do
                if move.toArea == Card.DiscardPile then
                    for _, info in ipairs(move.moveInfo) do
                        if Fk:getCardById(info.cardId):getMark("@@seeking_pendulum") ~= 0 then
                            return player:hasSkill(seeking_pendulum.name, true, true)
                        end
                    end
                end
            end
        end,
        on_refresh = function(self, event, target, player, data)
            local room = player.room
            local records = player:getTableMark("seeking_pendulum")
            local cards = {}
            for _, move in ipairs(data) do
                if move.toArea == Card.DiscardPile then
                    for _, info in ipairs(move.moveInfo) do
                        if Fk:getCardById(info.cardId):getMark("@@seeking_pendulum") ~= 0 and table.contains(records, info.cardId) then
                            table.insertIfNeed(cards, info.cardId)
                            table.removeOne(records, info.cardId)
                        end
                    end
                end
            end
            if #cards == 0 then
                return
            end
            room:setPlayerMark(player, "seeking_pendulum", records)
            room:sendLog {
                type = "#DestructCards",
                card = Card:getIdList(cards),
            }
            room:moveCardTo(cards, Card.Void, nil, fk.ReasonJustMove, seeking_pendulum.name)
        end
    })

    local gather_quest = fk.CreateSkill {
        name = "gather_quest",
    }
    gather_quest:addEffect(fk.CardUseFinished, {
        can_trigger = function(self, event, target, player, data)
            return player:hasSkill(gather_quest.name) and target ~= player and target.phase ~= Player.NotActive and player:getMark("gather_quest-turn") == 0 and not player:isKongcheng() and
                data.card.is_damage_card
        end,
        on_cost = function(self, event, target, player, data)
            local cards = {}
            for _, id in ipairs(player:getCardIds("h")) do
                if Fk:getCardById(id).is_damage_card then
                    table.insertIfNeed(cards, id)
                end
            end
            local result = player.room:askToCards(player, {
                skill_name = gather_quest.name,
                prompt = "gather_quest_prompt::" .. target.id,
                min_num = 1,
                max_num = 1,
                pattern = ".|.|.|.|.|.|" .. table.concat(cards, ",")
            })
            if #result > 0 then
                event:setCostData(self, result)
                return true
            end
        end,
        on_use = function(self, event, target, player, data)
            local room = player.room
            room:moveCardTo(event:getCostData(self), Card.PlayerHand, target, fk.ReasonGive, gather_quest.name, nil, false, player)
            room:drawCards(player, 1, gather_quest.name)
        end,

        late_refresh = true,
        can_refresh = function(self, event, target, player, data)
            return target ~= player and target.phase ~= Player.NotActive and player:getMark("gather_quest-turn") == 0 and data.card.is_damage_card
        end,
        on_refresh = function(self, event, target, player, data)
            player.room:setPlayerMark(player, "gather_quest-turn", 1)
        end
    })

    extension:loadSkillSkels { seeking_pendulum, gather_quest }
    hy_nazuurin:addSkills { "seeking_pendulum", "gather_quest" }

    Fk:loadTranslationTable {
        ["hy_nazuurin"] = "纳兹琳",
        ["#hy_nazuurin"] = "地洞寻宝",
        ["illustrator:hy_nazuurin"] = "イチルギ",
        ["designer:hy_nazuurin"] = "黑曜人形",
        ["cv:hy_nazuurin"] = "",

        ["seeking_pendulum"] = "灵探",
        [":seeking_pendulum"] = "每回合开始时，你获得牌堆顶两张牌中所有单目标伤害类牌的复制。以此法复制的牌无使用次数限制，每回合结束时或进入弃牌堆后销毁。",
        ["@@seeking_pendulum"] = "灵探",

        ["gather_quest"] = "委集",
        [":gather_quest"] = "其他角色于其回合内首次使用伤害类牌结算结束后，你可以交给其一张伤害类牌并摸一张牌。",
        ["gather_quest_prompt"] = "委集：你可以交给%dest一张伤害类牌并摸一张牌",
    }
end
